/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ssau.utils;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import ru.ssau.entities.AuthorizationInfoLocalHome;
import ru.ssau.entities.MessageLocalHome;
import ru.ssau.entities.ThreadLocalHome;
import ru.ssau.entities.UserLocalHome;


public class EntityUtil {

    private EntityUtil() {
        
    }

    public static ThreadLocalHome getThreadLocalHome() throws NamingException {
        Context namingContext = new InitialContext();
        ThreadLocalHome tHome = (ThreadLocalHome) namingContext.lookup("java:comp/env/ejb/ThreadBean");
        namingContext.close();
        return tHome;
    }

    public static MessageLocalHome getMessageLocalHome() throws NamingException {
        Context namingContext = new InitialContext();
        MessageLocalHome mHome = (MessageLocalHome) namingContext.lookup("java:comp/env/ejb/MessageBean");
        namingContext.close();
        return mHome;
    }

    public static UserLocalHome getUserLocalHome() throws NamingException {
        Context namingContext = new InitialContext();
        UserLocalHome uHome = (UserLocalHome) namingContext.lookup("java:comp/env/ejb/UserBean");
        namingContext.close();
        return uHome;
    }

    public static AuthorizationInfoLocalHome getAuthorizationInfoLocalHome() throws NamingException {
        Context namingContext = new InitialContext();
        AuthorizationInfoLocalHome aiHome = (AuthorizationInfoLocalHome) namingContext.lookup("java:comp/env/ejb/AuthorizationInfoBean");
        namingContext.close();
        return aiHome;
    }

}
